<template>
    <div class="xl-table">
        <xlUntil text="载体列表" :queryParam="queryParam" :add-btn="true" :untilVisible="false" @addForm="addForm" @delBatch="delBatch" @searchKeyWord="searchKeyWord" :searchColumns="columns">
            <template #search>
                <a-input v-model="queryParam.carrierName" placeholder="请输入载体名称" style="margin-right: 16px;width: 150px;"></a-input>
                <a-select v-model="queryParam.withInvestFlag" placeholder="是否为投融资企业" showSearch allowClear  style="margin-right: 16px;width: 162px;">
                    <a-select-option value="0">
                        否
                    </a-select-option>
                    <a-select-option value="1">
                        是
                    </a-select-option>
                </a-select>

                <a-select v-model="queryParam.withHighTechFlag" placeholder="是否为高企" showSearch allowClear  style="margin-right: 16px;width: 130px;">
                    <a-select-option value="0">
                        否
                    </a-select-option>
                    <a-select-option value="1">
                        是
                    </a-select-option>
                </a-select>

                <a-select v-model="queryParam.withProjectAwardFlag" placeholder="是否获得过市项目企业" showSearch allowClear  style="margin-right: 16px;width: 187px;">
                    <a-select-option value="0">
                        否
                    </a-select-option>
                    <a-select-option value="1">
                        是
                    </a-select-option>
                </a-select>
            </template>
        </xlUntil>
        <div class="xl-table-content">
            <xlTable
                    :columns="columns"
                    :dataSource="data"
                    rowKey="id"
                    :pagination="pagination"
                    :loading="loading"
                    @change="handleTableChange"
                    bordered
                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
                >
                <template v-slot:action="scope">
                    <a @click="editForm(scope.record)">编辑</a>
                    <a-divider type="vertical"/>
                    <a-dropdown>
                        <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
                        <a-menu slot="overlay">
                            <a-menu-item @click="seeForm(scope.record)">
                                <a>查看</a>
                            </a-menu-item>
                            <a-menu-item>
                                <a-popconfirm title="确定删除吗?" @confirm="() => delForm(scope.record.id)">
                                    <a>删除</a>
                                </a-popconfirm>
                            </a-menu-item>
                        </a-menu>
                    </a-dropdown>
                </template>

            </xlTable>
        </div>
        <xlForm ref="xlForm" @handleOk="handleOk" @pageOnload="pageOnload"></xlForm>
        <seeForm ref="seeForm"></seeForm>
        <carrierForm ref="carrierForm"></carrierForm>
        <activityForm ref="activityForm"></activityForm>
    </div>
</template>

<script>

    import xlMixin from '../../../../components/mixin'
    import seeForm from './model/see'
    import xlForm from './model/form'
    import activityForm from './model/activityForm'
    import carrierForm from './model/carrierForm'
    export default {
        name: "index",
        mixins:[xlMixin],
        data(){
            return{
                columns:[
                    {
                        title: '序号',
                        key: 'rowIndex',
                        align: "center",
                        width:'100px',
                        sorter: (a) => a.id,//排序
                        customRender: function (t, r, index) {
                            return parseInt(index) + 1;
                        }
                    },
                    {
                        title: '运营机构名称',
                        width:'200px',
                        dataIndex: 'comName',
                        type:'input'
                    },
                    {
                        title: '载体名称',
                        width:'200px',
                        dataIndex: 'carrierName',
                        type:'input'
                    },
                    {
                        title: '载体成立时间',
                        dataIndex: 'carrierRegDate',
                        type:'date',
                        width:"130px",
                    },
                    {
                        title: '载体类型',
                        dataIndex: 'carrierType',
                        type:'select',
                        width:"150px",
                        typeData:[
                            {
                                dataName:'孵化器',
                                dataValue:'1'
                            },
                            {
                                dataName:'众创空间',
                                dataValue:'2'
                            },
                            {
                                dataName:'新型研发机构',
                                dataValue:'3'
                            },
                            {
                                dataName:'硅巷',
                                dataValue:'4'
                            }
                        ]
                    },
                    {
                        title: '载体类别',
                        dataIndex: 'comKind',
                        type:'select',
                        width:"150px",
                        typeData:[
                            {
                                dataName:'综合',
                                dataValue:'1'
                            },
                            {
                                dataName:'专业',
                                dataValue:'2'
                            }
                        ]
                    },
                    {
                        title: '载体级别',
                        dataIndex: 'carrierLevel',
                        width:"150px",
                        type:'select',
                        typeData:'CARRIER_LEVEL'
                    },
                    {
                        title: '机构性质',
                        dataIndex: 'comNature',
                        type:'select',
                        width:"150px",
                        typeData:'COM_NATURE'
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: "center",
                        
                        width:'150px',
                        scopedSlots: {customRender: 'action'},
                    }
                ],
                paramMore:{
                    // carrierType:''
                },
                url: {
                    list: "/system/api/carrierBasicInfo/pageList",
                    add: "/system/api/carrierBasicInfo/save",
                    edit: "/system/api/carrierBasicInfo/update",
                    delete: "/system/api/carrierBasicInfo/remove",
                    deleteBatch: "/system/api/carrierBasicInfo/remove",
                    exportXlsUrl: "/ndo/api/new/dev/org/export/team/members",
                    importExcelUrl: "/person/project/upload/cjjn"
                }
            }
        },
        components:{
            seeForm,
            xlForm,
            carrierForm,
            activityForm
        },
        created(){
            this.formatMerge()
            this.pageOnload()
        },
        methods:{
            addForm() {
                this.$refs.xlForm.tableTitle = '新增'
                this.$refs.xlForm.formatForm({
                    regulationType:'', 
                    facilityType:''
                })
                this.$refs.xlForm.visible = true
                this.$refs.xlForm.type = 1
            },
            editForm(data) {
                this.$refs.xlForm.tableTitle = '修改'
                this.$refs.xlForm.formatForm(data)
                this.$refs.xlForm.visible = true
                this.$refs.xlForm.type = 2
            },
            seeForm(data) {
                //修改方法
                this.$refs.seeForm.visible = true
                this.$refs.seeForm.confirmLoading = false
                this.$refs.seeForm.formatForm(data)
                this.$refs.seeForm.type = 2
                //赋值表单数据
            },
            carrierForm(data,number){
                this.$refs.carrierForm.visible = true
                if(number == 1){
                    this.$refs.carrierForm.formatForm(data,1)
                    this.$refs.carrierForm.pageOnload()
                }
                if(number == 2){
                     this.$refs.carrierForm.formatForm(data,2)
                     this.$refs.carrierForm.pageOnload()
                }
                if(number == 3){
                    this.$refs.carrierForm.formatForm(data,3)
                    this.$refs.carrierForm.pageOnload()
                }
                if(number == 4){
                    this.$refs.carrierForm.formatForm(data,4)
                    this.$refs.carrierForm.pageOnload()
                }
            }
        }
    }
</script>

<style scoped lang="less">
    .xl-table{
        .xl-table-content{
            padding: 16px;
        }
    }
</style>
